import os
from zhipuai import ZhipuAI


zhipuai_api_key = os.getenv('ZP_API_KEY')
client = ZhipuAI(api_key=zhipuai_api_key)
prompt = "今天为啥股市大跌"
response = client.chat.completions.create(
    model="glm-4-flash",
    messages=[
        {"role": "user", "content": prompt},
    ],
    stream=True
)

for chunk in response:
    print(chunk.choices[0].delta.content,end="")